<template>
  <h1>我是子组件1</h1>
  <div>{{ message }}</div>
  <button @click="sendMessage">给父组件发消息</button>
</template>

<script setup>
defineProps({
  message: String,
});
const emit = defineEmits(['message-sent']);
function sendMessage() {
  alert('子组件发送消息给父组件');
  emit('message-sent', '来自子组件的消息');
}
</script>